$(document)
		.ready(
				function() {

					$
							.ajax({
								type : "post",
								url : "articleQuwenList",
								async : true,
								dataType : 'json',
								success : function(data) {

									console.log(data)

									var articlePath = 'myAssets//img//article//';// 文章文件路径
									var facePath = 'myAssets//img//face//';// 头像文件路径

									var list = data.listVo;// 文章数组
									for (var i = 0; i < list.length; i++) {

										var id = list[i].id;
										var title = list[i].title;// 标题
										var content = list[i].content;// 内容
										var user = list[i].user;// 内容
										var dateProbably = getDateDiff(list[i].date
												.replace("T", " "));

										if (list[i].myFiles.length == 0) {
											console.log('文章id' + id)
											console.log('用户id' + user.id)
											$("#articel-List")
													.append(
															' <!--框1 --> <li class="am-g am-list-item-desced am_list_li"> <div class=" am-list-main"> <h3 class="am-list-item-hd am_list_title am_list_title_s">  <a href=articleQuwenOne?id='
																	+ id
																	+ ' class="">'
																	+ title
																	+ '</a></h3> <div class="am_list_author"><a href=heUser?id='
																	+ user.id
																	+ '><span class="am_list_author_ico" style="background-image: url('
																	+ facePath
																	+ user.myFile.name
																	+ ');"></span><span class="name">'
																	+ user.name
																	+ '</span></a><span class="am_news_time">&nbsp;•&nbsp;<time class="timeago">'
																	+ dateProbably
																	+ '</time></span></div> <div class="am-list-item-text am_list_item_text">'
																	+ content
																	+ '</div>  </div> </li>');
										} else {
											$("#articel-List")
													.append(
															' <!--框1 --> <li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left am_list_li">  <div class="am-u-sm-3 am-list-thumb am_list_thumb">    <a href=articleQuwenOne?id='
																	+ id
																	+ ' class="">  <img src="'
																	+ articlePath
																	+ list[i].myFiles[0].name
																	+ '" class="am_news_list_img" alt=""   />   </a>  </div>  <div class=" am-u-sm-9 am-list-main am_list_main">   <h3 class="am-list-item-hd am_list_title">    <a href=articleQuwenOne?id='
																	+ id
																	+ ' class="">'
																	+ title
																	+ '</a>      </h3>  <div class="am_list_author"><a href=heUser?id='
																	+ user.id
																	+ '><span class="am_list_author_ico" style="background-image: url('
																	+ facePath
																	+ user.myFile.name
																	+ ');"></span><span class="name">'
																	+ user.name
																	+ '</span></a><span class="am_news_time">&nbsp;•&nbsp;<time class="timeago">'
																	+ dateProbably
																	+ '</time></span></div>   <div class="am-list-item-text am_list_item_text ">'
																	+ content
																	+ '</div>  </div>   </li>');
										}

									}

									// console.log(CurentTime())
								},
								error : function() {
								}
							});

				})

// 获取当前时间方法
function CurentTime() {
	var now = new Date();
	var year = now.getFullYear(); // 年
	var month = now.getMonth() + 1; // 月
	var day = now.getDate(); // 日
	var hh = now.getHours(); // 时
	var mm = now.getMinutes(); // 分
	var clock = year + "-";
	if (month < 10)
		clock += "0";
	clock += month + "-";
	if (day < 10)
		clock += "0";
	clock += day + " ";
	if (hh < 10)
		clock += "0";
	clock += hh + ":";
	if (mm < 10)
		clock += '0';
	clock += mm;
	return (clock);
}
// 发布时间'2017-03-26T09:29:34' 返回"几天前"
function getDateDiff(dateTimeStamp) {
	dateTimeStamp = Date.parse(dateTimeStamp.replace(/-/gi, "/"));
	var minute = 1000 * 60;
	var hour = minute * 60;
	var day = hour * 24;
	var halfamonth = day * 15;
	var month = day * 30;
	var now = new Date().getTime();
	var diffValue = now - dateTimeStamp;
	if (diffValue < 0) {
		return;
	}
	var monthC = diffValue / month;
	var weekC = diffValue / (7 * day);
	var dayC = diffValue / day;
	var hourC = diffValue / hour;
	var minC = diffValue / minute;
	if (monthC >= 1) {
		result = "" + parseInt(monthC) + "月前";
	} else if (weekC >= 1) {
		result = "" + parseInt(weekC) + "周前";
	} else if (dayC >= 1) {
		result = "" + parseInt(dayC) + "天前";
	} else if (hourC >= 1) {
		result = "" + parseInt(hourC) + "小时前";
	} else if (minC >= 1) {
		result = "" + parseInt(minC) + "分钟前";
	} else
		result = "刚刚";
	return result;
}
